package com.service.impl;

import com.dao.UserDao;
import com.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Primary;
import org.springframework.stereotype.Service;

@Primary
@Service
public class UserServiceImpl implements UserService {
    //加了 @Qualifier 就是通过名称装配
    //1、通过属性名装配
//    @Autowired
    UserDao userDao;

/*    public UserServiceImpl() {
    }*/
    //2、通过构造函数装配
    //构造函数上不能添加@Qualifier
    //@Autowired
    public UserServiceImpl(@Autowired UserDao userDao) {
        this.userDao = userDao;
        System.out.println("构造函数装配");
    }

    //3、setter方法
    //@Autowired
    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    @Override
    public void save() {
        userDao.save();
    }
}
